package com.supplychain.scm.core.feign.interceptor;

import com.supplychain.scm.core.common.constant.RequestConstants;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.slf4j.MDC;

/**
 * @author liyang
 * @version 1.0.0
 * @ClassName RequestHeaderInterceptor
 * @Description 统一添加请求头
 * @createTime 08:54:00 2023/05/22
 */
public class RequestHeaderInterceptor implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate requestTemplate) {
        requestTemplate.header(RequestConstants.REQUEST_ID, MDC.get(RequestConstants.REQUEST_ID));
        // 处理OkHttp3 java.io.IOException: unexpected end of stream on Connection caused by java.io.EOFExcep
        requestTemplate.header("Connection","close");
        requestTemplate.header("Accept-Encoding", "identity");
    }
}
